package com.bolang.onlycode.demo.MyThread;


import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 生产者消费者问题
 */
public class MyThread {
    public static void main(String[] args) {
        /**
         * 新建一个水桶，存放所有的水，刚开始水桶是空的，容量为5L
         */
        List<Water> waterList = new ArrayList<>(5);

        Producer provider = new Producer(waterList);
        Consumer consumer = new Consumer(waterList);
        Consumer consumer1 = new Consumer(waterList);
        Thread thread1 =new Thread(provider);
        Thread thread2 =new Thread(consumer);
        Thread thread3 =new Thread(consumer1);
        thread1.setName("农夫山泉一号");
        thread2.start();
        thread3.start();
       thread1.start();
    }
}